import debounce from '@common/debounce'
import BackTop from '@contentcpn/backTop/BackTop'

export const itemLoad = {
  data() {
    return {
      imgLoadListener: null,
      refresh: null
    }
  },
  mounted() {
    this.refresh = debounce(this.$refs.scroll.refresh, 50)
    this.imgLoadListener = () => {
      this.refresh()
    }
    this.$bus.$on('imgLoad', this.imgLoadListener)
  }
}

export const backTop = {
  components: { BackTop },
  data() {
    return {
      isBackTopShow: false
    }
  },
  methods: {
    backTopClick() {
      this.$refs.scroll.scrollTo(0, 0)
    },
    showBackTop(position) {
      this.isBackTopShow = -position.y > 1000
    }
  }
}
